package com.example.a22310.myapplication.Model;


import com.example.a22310.myapplication.Beans.Race;
import com.example.a22310.myapplication.Listener.ActivityLisenter;
import com.example.a22310.myapplication.Service.service;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static android.provider.ContactsContract.CommonDataKinds.Website.URL;

public class RaceModel {
    private Retrofit retrofit;
    public RaceModel()
    {

        retrofit= new Retrofit.Builder()
                .baseUrl(URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }

    public void Racelist(final ActivityLisenter<Race> lisenter) {  //活动部列表
        service service = retrofit.create(service.class);
        Call<Race> call = service.racelist();
        Callback<Race> callback = new Callback<Race>() {
            @Override
            public void onResponse(Call<Race> call, Response<Race> response) {
                Race race= response.body();
                lisenter.onSuccess(race);
            }
            @Override

            public void onFailure(Call<Race> call, Throwable t) {
                lisenter.onFailure();
            }
        };
        call.enqueue(callback);
    }


}
